import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {AppComponent} from './app.component';
import {RouterModule} from '@angular/router';
import {rootRoutes} from './app.routes';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {CommonModule} from '@angular/common';
import {HTTP_INTERCEPTORS, HttpClient, HttpClientModule} from '@angular/common/http';
import {SharedComponentModule} from './shared/components/component.module';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {TranslateLoaderFactory} from './shared/utils/translate-loader-factory';
import {ServiceModule} from './shared/services/service.module';
import {DefaultHttpInterceptor} from './shared/utils/default-http-interceptor';
import {SystemModule} from './page/system/system.module';
import * as AllIcons from '@ant-design/icons-angular/icons';
import {IconDefinition} from '@ant-design/icons-angular';
import {BusinessModule} from './page/business/business.module';
import {InitDataService} from './services/system/init.data.service';
import {NgxsModule} from '@ngxs/store';
import {BpsState} from './page/system/layout/header/header';
import {NZ_I18N, zh_CN} from 'ng-zorro-antd/i18n';
import {NZ_ICONS} from 'ng-zorro-antd/icon';
import {NgZorroAntdModule} from './ng-zorro-antd.module';
import {NgxChartsModule} from '@swimlane/ngx-charts';

const antDesignIcons = AllIcons as {
  [key: string]: IconDefinition;
};
const icons: IconDefinition[] = Object.keys(antDesignIcons).map(key => antDesignIcons[key]);


@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    CommonModule,
    FormsModule,
    NgxChartsModule,
    NgxsModule.forRoot([BpsState]),
    ReactiveFormsModule,
    NgZorroAntdModule,
    ServiceModule,
    SystemModule,
    BusinessModule,
    SharedComponentModule,
    RouterModule.forRoot(rootRoutes),
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: TranslateLoaderFactory,
        deps: [HttpClient]
      }
    })
  ],
  providers: [
    {
    provide: InitDataService,
    useValue: undefined
},
    {
      provide: HTTP_INTERCEPTORS,
      useClass: DefaultHttpInterceptor,
      multi: true,
    },
    {
      provide: NZ_ICONS,
      useValue: icons
    },
    {
      provide: NZ_I18N,
      useValue: zh_CN
    }
  ],
  bootstrap: [AppComponent],
})
export class AppModule {
}
